﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataTray" @search="()=>{getTableDataTray();}">
      <el-row>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="TrayCode_FormItem" prop="TrayCode" :label="$t('message.autotrans._Model_Tray_TrayCode')">
            <el-input v-model="searchDataTray.TrayCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="TrayName_FormItem" prop="TrayName" :label="$t('message.autotrans._Model_Tray_TrayName')">
            <el-input v-model="searchDataTray.TrayName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="TrayDescription_FormItem" prop="TrayDescription" :label="$t('message.autotrans._Model_Tray_TrayDescription')">
            <el-input v-model="searchDataTray.TrayDescription" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="TrayStatus_FormItem" prop="TrayStatus" :label="$t('message.autotrans._Model_Tray_TrayStatus')">
            <el-input v-model="searchDataTray.TrayStatus" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Note_FormItem" prop="Note" :label="$t('message.autotrans._Model_Tray_Note')">
            <el-input v-model="searchDataTray.Note" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="TrayLine_FormItem" prop="TrayLine" :label="$t('message.autotrans._Model_Tray_TrayLine')">
            <el-input v-model="searchDataTray.TrayLine" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="TrayStation_FormItem" prop="TrayStation" :label="$t('message.autotrans._Model_Tray_TrayStation')">
            <el-input v-model="searchDataTray.TrayStation" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UsedTimes_FormItem" prop="UsedTimes" :label="$t('message.autotrans._Model_Tray_UsedTimes')">
            <el-input v-model="searchDataTray.UsedTimes" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="PlannedTimes_FormItem" prop="PlannedTimes" :label="$t('message.autotrans._Model_Tray_PlannedTimes')">
            <el-input v-model="searchDataTray.PlannedTimes" clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
      <WtmButton v-auth="'/api/BaseInformation/Tray/Create'" icon='fa fa-plus' type='primary' :button-text="$t('message.autotrans.SysCreate')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/BaseInformation/Tray/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/BaseInformation/Tray/BatchEdit'" icon='fa fa-pencil-square' type='primary' :button-text="$t('message.autotrans.SysBatchEdit')" @click="OnBatchEditClick()"/>
    <WtmButton v-auth="'/api/BaseInformation/Tray/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message.autotrans.SysImport')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/BaseInformation/Tray/TrayExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message.autotrans.SysExport')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefTray" v-bind="tableDataTray">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
            <WtmButton v-auth="'/api/BaseInformation/Tray/Edit'" :is-text="true" icon='fa fa-pencil-square' type='warning' :button-text="$t('message.autotrans.SysEdit')" @click="OnEditrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/BaseInformation/Tray/{id}'" :is-text="true" icon='fa fa-info-circle' type='info' :button-text="$t('message.autotrans.Page详情')" @click="OnDetailsrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/BaseInformation/Tray/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" :is-text="true"  @click="onDelete(scope.row)"/>

        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageBaseInformationTrayIndex;true;TyMES.BaseInformation.Controllers;Tray">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { trayApi } from '/@/api/baseinformation/tray';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const BatchEditDialog = defineAsyncComponent(() => import('./batchedit.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateTray = reactive({
    
});

const searchDataTray = ref({
        TrayCode: '',
        TrayName: '',
        TrayDescription: '',
        TrayStatus: '',
        Note: '',
        TrayLine: '',
        TrayStation: '',
        UsedTimes: null,
        PlannedTimes: null,
});

// 定义变量内容
const tableRefTray = ref();
const tableDataTray = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
      {title:ci.proxy.$t('message.autotrans.Page托盘编码'),key: 'Tray_TrayCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page托盘名称'),key: 'Tray_TrayName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page描述'),key: 'Tray_TrayDescription',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page状态'),key: 'Tray_TrayStatus',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminRemark'),key: 'Tray_Note',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page当前产线'),key: 'Tray_TrayLine',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page当前工位'),key: 'Tray_TrayStation',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page使用寿命'),key: 'Tray_UsedTimes',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page预计寿命'),key: 'Tray_PlannedTimes',type: 'text',isCheck: true},

	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataTray = () => {
    tableRefTray.value.doSearch(trayApi().search, searchDataTray.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysCreate'), CreateDialog, null, getTableDataTray)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysEdit'), EditDialog, row, getTableDataTray)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.Page详情'), DetailsDialog, row, getTableDataTray)
};

// 删除
const onDelete = (row: any) => {
    trayApi().delete([row.ID]).then(() => { getTableDataTray()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefTray.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      trayApi().delete(selectedids).then(() => { getTableDataTray()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnBatchEditClick = () => {
    const selectedrows = tableRefTray.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      other.openDialog(ci.proxy.$t('message.autotrans.SysBatchEdit'), BatchEditDialog, selectedids, getTableDataTray)
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysImport'), ImportDialog, null, getTableDataTray)
};

const onExport = () => {
	const selected = tableRefTray.value.getSelectedRows();
	if (selected.length > 0) {
		trayApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		trayApi().export({});
	}
};

// 页面加载时
onMounted(() => {
    
        getTableDataTray();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

